/*
 * PathRing
 * 
 * initial implementation : 4.9.2007
 *
 * Copyright (c) Adam Sida, asida@centrum.cz.
 * All rights reserved.
 * 
 * for license see Petra.Gis.License.txt
 */
using System;
//using System.Collections.Generic;
//using System.Text;
//using Petra.Gis.Geometry.Support;


namespace Petra.Gis.Geometry
{
  /// <summary>
  /// pathRingGeometry is object that stores multiple linear components
  /// that encloses area where each previous geometry must extend next one from same point
  /// firstElement.startPoint = lastElement.endPoint
  /// geometry is not valid since firstElement.startPoint != lastElement.lastPoint
  /// pathRingGeometry don't accept enclosed single ring (Element.startPoint = Element.lastPoint), will raise error
  /// </summary>
  public class PathRing : GeometryCollection
  {

    static PathRing()
    {
      /*sGeometryType = GeometryTypes.PATHRING_GEOMETRY;
      typeLimits = new GeometryTypes[] { GeometryTypes.ARC_GEOMETRY, GeometryTypes.LINESTRING_GEOMETRY };
       */
    }




    public override void Add(GeometryBase oGeom)
    {
      Curve tmpGeom = (Curve)oGeom;
      //validate if input component startPoint == endPoint, invalid geometry input !!
      if (tmpGeom.coordList.startPoint.Equals(tmpGeom.coordList.endPoint, tmpGeom.coordList.dimension))
        throw new ArgumentException("can't add geometry which startPoint = endPoint (enclosed)");

      if (this.Count == 0)
        base.Add(oGeom);
      else
      {
        //valiate if last point of prev is same as first of current !!
        tmpGeom = (Curve)this[this.Count - 1];
        if (tmpGeom.coordList.endPoint.Equals(((Curve)oGeom).coordList.startPoint, tmpGeom.coordList.dimension))
          throw new ArgumentException("can't add geometry which startPoint don't match polylineGeometry last component.endPoint");
        else
          base.Add(oGeom);
      }
    }


  }
}
